package com.xce.order.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName ExchangeConfig
 * @Description 广播交换机
 * @Author lld
 * @Date 2025/6/12 1:14
 * @Version 1.0
 */
@Configuration
public class ExchangeConfig {

    // 交换机
    @Bean
    public FanoutExchange simpleExchange() {
        return new FanoutExchange("simple.exchange");
    }
    // 队列
    @Bean
    public Queue simpleQueue() {
        return new Queue("simple.queue");
    }

    @Bean
    public Queue workQueue() {
        return new Queue("work.queue");
    }
    // 绑定关系
    @Bean
    public Binding binding(FanoutExchange simpleExchange, Queue simpleQueue) {
        return BindingBuilder.bind(simpleQueue).to(simpleExchange);
    }

}
